<?php $str = $action=='update'?'Cập nhật':'Thêm mới'; ?>

<div class="row">
	<div class="col-md-12 col-xs-12">
        <h1>
            <p class="pull-left">Danh mục sản phẩm <small>Quản lý các danh mục sản phẩm</small></p>
            <p class="pull-right">
                <?php if($action=='update') { ?>
                <a class="btn btn-primary" href="<?php echo admin_page_url(CATEGORY_SLUG.'/'.INSERT_SLUG); ?>">
                    <i class="glyphicon glyphicon-plus-sign"></i> Thêm mới
                </a>
                <?php } ?>
                <button type="button" class="btn btn-success" onclick="wireOfAction('#btn-update', 'click');">
                    <i class="glyphicon glyphicon-ok-sign"></i> <?php echo $str; ?>
                </button>
                <a class="btn btn-default" href="<?php echo admin_page_url(CATEGORY_SLUG); ?>">
                    <i class="glyphicon glyphicon-share-alt"></i> Trở về
                </a>
            </p>
        </h1>
    </div>
    <div class="col-md-12">
      <ol class="breadcrumb">
        <li><a href="<?php echo admin_page_url(); ?>"><i class="fa fa-dashboard"></i> Dashboard</a></li>
        <li><a href="<?php echo admin_category_url(); ?>"><i class="fa fa-table"></i> Danh mục</a></li>
    </ol>
</div>
</div>

<div class='row' id="panel-new-category-cate">
    <h1 class="col-md-12"><?php echo $str; ?></h1>
    <form role="form" method="post" action="<?php echo $action_link; ?>" data-callback="1">
        <div class="col-md-2 col-xs-12">
            <a class="thumbnail" id="a-input-category-icon" href="#" title="Chọn hình đại diện" data-toggle="modal" data-target="#modal-change-img">
                <?php if($oCate->getIcon()!='') { ?>
                <img src="<?php echo upload(CATEGORY_IMAGE_URL.$oCate->getIcon()); ?>" />
                <?php } else { ?>
                <img data-src="holder.js/96x96" />
                <?php }?>
            </a>
        </div>
        <div class="col-md-4 col-xs-12">
            <div class="form-group">
                <label for="input-category-title">Tên danh mục</label>
                <input type="text" class="form-control auto-slug" follow-ctr='#input-category-slug' id="input-category-title" name="category[title]" value="<?php echo $oCate->getTitle(); ?>" />
            </div>
            <div class="form-group">
                <label for="input-category-template">Đường dẫn</label>
                <input type="text" class="form-control" id="input-category-slug" name="category[slug]" value="<?php echo $oCate->getSlug(); ?>"/>
            </div>
            <div class="form-group">
                <label for="input-category-order">Thứ tự</label>
                <input type="text" class="form-control" id="input-category-order" name="category[order]" value="<?php echo $oCate->getOrder(); ?>" />
            </div>
            <div class="form-group">
                <label>Hiển thị</label>
                <input type="checkbox" id="input-category-delete-flg" class="lb-toggle" name="category[publish_flg]" value="1"
                <?php echo $oCate->getDeletedAt()==NULL?"checked='checked'":""; ?> />
                <label for="input-category-delete-flg"></label>
            </div>
            <div class="form-group">
                <?php
                    $str = "";
                    $path = "";
                    if($action=='update'){
                        $str = 'Cập nhật';
                        $path = CATEGORY_IMAGE_URL.$oCate->getIcon();
                    } else {
                        $str = 'Thêm mới';
                        $path = "";
                    }
                ?>

                <button type="button" class="btn btn-success btn-submit-update" id="btn-update"><i class="glyphicon glyphicon-ok-sign"></i> <?php echo $str; ?></button>
                <a class="btn btn-default" href="<?php echo admin_page_url(CATEGORY_SLUG); ?>">
                    <i class="glyphicon glyphicon-share-alt"></i> Trở về
                </a>
                <input type="hidden" name="category[icon]" value="<?php echo $path; ?>" id="input-category-icon" />
                <?php if($action=='update') { ?>
                <input type="hidden" name="category[id]" value="<?php echo $this->encrypt->encode($oCate->getId()); ?>" />
                <?php } ?>
            </div>
        </div>
        <div class="clearfix"></div>
    </form>
</div>
<?php $this->load->view('backend/admin/image-modal/category.html.php'); ?>